from core.agent import Agent

class InductiveOptimist(Agent):
    """
    Invests in the first round. Then performs the action that would have
    maximized utility in the previous round.
    """
    
    def decide(self, my_id, info):
        # In the first round, invest
        if info.current_round == 1:
            return True
        # Calculate expected utility of investing in the last round
        d = info.all_decisions()
        d[my_id] = True
        invest = info.p_negevent(my_id,d) * info.cost_of_negevent + info.cost_of_investing
        # Calculate expected utility of not investing in the last round
        d[my_id] = False
        ninvest = info.p_negevent(my_id,d) * info.cost_of_negevent
        # Choose the action with the highest expected utility (but invest if there is a tie)
        return invest >= ninvest